@import './abstracts/variable';
@import './abstracts/mixin';

@include b(loading) {
  font-size: 0;
  line-height: 0;
  vertical-align: middle;

  @include e(spinner) {
    display: block;
    width: 100%;
    height: 100%;
    animation: wd-rotate 0.8s linear infinite;
  }
  @include m(circle) {
    animation-duration: 2s;
    
    circle {
      stroke: currentColor;
      stroke-width: 3;
      stroke-linecap: round;
      animation: wd-circular 1.5s ease-in-out infinite;
    }
  }
  @include m(spinner) {
    animation-timing-function: steps(12);
  }
  @include e(spinner-dot) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    &::before {
      display: block;
      content: '';
      width: 2px;
      height: 25%;
      border-radius: 1px;
      margin: 0 auto;
      background: currentColor;
    }
  }
}

@for $i from 1 through 12 {
  .wd-loading__spinner-dot:nth-of-type(#{$i}) {
    opacity: 1 - (0.75 / 12) * ($i - 1);
    transform: rotate($i * 30deg);
  }
}

@keyframes wd-circular {
  0% {
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
  }

  50% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -40;
  }

  100% {
    stroke-dasharray: 90, 150;
    stroke-dashoffset: -120;
  }
}

@keyframes wd-rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}
